<template>
	<view>
		<view>{{ $t('search:device') }}</view>
		<upload></upload>
		<view id="olMap" class="olMap">
		</view>
	</view>
</template>

<script>
import { pages,getHmd } from '@/api/work/equipment.js'
import upload from '@/components/upload/index.vue'
import "../../../static/js/ol.js";
export default {
  components:{upload},
  data() {
	return {
		list:[],
		map: null,
	}
  },
  created() {
    this.getPages()
	this.getHmd()
  },
  mounted() {
	  var that = this
		setTimeout(function(){
			// that.initAmap()
		},1000)
	},
  methods: {
	 //  initAmap() {
		//       // 设置地图中心，此处进行坐标转换， 把EPSG:4326(经纬度坐标)，转换为EPSG:3857(WGS84网络墨卡托(辅助球))坐标，因为ol默认使用的是EPSG:3857坐标
		//       let centerPos = ol.proj.transform([117.27, 31.68], 'EPSG:4326', 'EPSG:3857');
		  
		//       //创建地图
		//       let map = new ol.Map({
		//           view: new ol.View({
		//               center: centerPos,//地图中心位置
		//               zoom: 10,//地图初始层级
		//               maxZoom: 15,
		//               minZoom: 9
		//           }),
		//           target: 'map'
		//       });
		  
		//       map.on('click', function (e) {
		//           // alert('X ; '+ e.clientX  + 'Y: '+e.clientY);
		//           let t = ol.proj.transform(map.getEventCoordinate(event), 'EPSG:3857', 'EPSG:4326');
		//           alert("鼠标点击处的经纬度：" + t);
		//       });
		  
		//       //给8位字符串文件名补0
		//       function zeroFill(num, len, radix) {
		//           var str = num.toString(radix || 10);
		//           while (str.length < len) {
		//               str = "0" + str;
		//           }
		//           return str;
		//       }
		  
		//       // ol.source.XYZ添加瓦片地图的层
		//       let tileLayer = new ol.layer.Tile({
		//           source: new ol.source.XYZ({
		//               tileUrlFunction: function (coordinate) {
		//                   //alert(coordinate[0] + " X= " + coordinate[1] + " Y= " + coordinate[2]);
		//                   var x = 'C' + zeroFill(coordinate[1], 8, 16);
		//                   var y = 'R' + zeroFill(-coordinate[2] - 1, 8, 16);
		//                   var z = 'L' + zeroFill(coordinate[0], 2, 10);
		//                   return '../../../static/map/' + z + '/' + y + '/' + x + '.png';//这里可以修改地图路径
		//               },
		//               projection: 'EPSG:3857'
		//           })
		//       });
		//       map.addLayer(tileLayer);//添加到map里面
		// },
    getPages(){
		var params = {
			"deviceCameraClass": "",
			"deviceCameraName": "",
			"deviceCameraId": "",
			"deviceCameraType": "",
			"sceneIds": [],
			"sceneNames": [],
			"heartbeatStatus": null,
			"deviceCameraClassList": [],
			"captureTimeType": 168,
			"captureTime": [
				1662965995000,
				1663570794000
			],
			"currentPage": 1,
			"pageSize": 10,
			"isDelete": 1,
			"regionId": "",
			"captureTimeB": 1662965995000,
			"captureTimeE": 1663570794000,
			"isQueryCaptureCount": true
		}
		pages(params).then(res => {
		})
	},
	getHmd(){
		var params = {
		    "pageSize": 4,
		    "pageIndex": 1,
		    "searchParams": {
		       
		    }
		}
		getHmd(params).then(res => {
		})
	}
  }
}
</script>

<style>
	.olMap {
			width: 100vw;
			height: 300px;
		}
</style>